﻿@using Microsoft.AspNet.Identity
@using HelpInfo.GetMsWeb.Models
@using HelpInfo.GetMsWeb.Resources.Views.Shared


@if (Request.IsAuthenticated)
{
    progetEntities db = new progetEntities();
    Agent currentUser = db.Agents.SingleOrDefault(user => user.Matricule == User.Identity.Name);
    
    using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm", @class = "navbar-right" }))
    {
    @Html.AntiForgeryToken()

        // Si l'utilisateur n'est pas un Agent
        if (currentUser == null)
        {
            <ul class="nav navbar-nav navbar-right">
                <li>
                    @Html.ActionLink( _Layout.Hello  + User.Identity.GetUserName() + "!", "Manage", "Account", routeValues: null, htmlAttributes: new { title = "Administrer" })
                </li>
                <li><a href="javascript:document.getElementById('logoutForm').submit()">@_Layout.Logout</a></li>
            </ul>
        }
        else
        {
            <ul class="nav navbar-nav navbar-right">
                <li>
                    @Html.ActionLink( _Layout.Hello + currentUser.Nom + " " + currentUser.Prénom + "!", "Manage", "Account", routeValues: null, htmlAttributes: new { title = "Administrer" })
                </li>
                <li><a href="javascript:document.getElementById('logoutForm').submit()">@_Layout.Logout </a></li>
            </ul>
        }
    }
}
else
{
    <ul class="nav navbar-nav navbar-right">
        <li>@Html.ActionLink(_Layout.Register, "Register", "Account", routeValues: null, htmlAttributes: new { id = "registerLink" })</li>
        <li>@Html.ActionLink(_Layout.Login, "Login", "Account", routeValues: null, htmlAttributes: new { id = "loginLink" })</li>
    </ul>
}
